#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Solution {
public:
    vector<vector<int>> combine(int n, int k) {
        vector<vector<int>> result;
        vector<int> current;
        backtrack(n, k, result, current, 1);
        return result;
    }
private:
    void backtrack(int n, int k, vector<vector<int>>& result, vector<int>& current, int start) {
        if (current.size() == k) { result.push_back(current); return; }
        for (int i = start; i <= n; i++) {
            current.push_back(i);
            backtrack(n, k, result, current, i + 1);
            current.pop_back();
        }
    }
};